package com.study.demo;

import com.study.demo.agency.BiToolFactory;
import com.study.demo.agency.ManToolFactory;
import com.study.demo.agency.impl.BiToolImpl;
import com.study.demo.agency.impl.ManToolImpl;
import com.study.demo.agency.impl.UserOne;
import com.study.demo.proxy.CompanyProxy;

public class Test {
	public static void main(String[] args) {
		
		System.out.println("----------------静态代理-------------------");
		//UserOne代理原对象ManToolFactory对进行业务增强 静态代理
		UserOne user=new UserOne(new ManToolImpl());
		user.saleMan("12");
		System.out.println("-----------------动态代理A公司------------------");
		//产品公司代理类
		ManToolFactory manToolFactory= new ManToolImpl();
		//笔公司代理类
		BiToolFactory biToolFactory=new BiToolImpl();
		
		CompanyProxy companyProxy=new CompanyProxy(manToolFactory);
		
		ManToolFactory manTool1=(ManToolFactory) companyProxy.getInvokeHandler();
		manTool1.saleMan("哈哈");
		System.out.println("-----------------动态代理B公司------------------");
		
		CompanyProxy companyProxB=new CompanyProxy(biToolFactory);
		BiToolFactory biTool1=(BiToolFactory) companyProxB.getInvokeHandler();
		biTool1.saleBi("6666");
	}

}
